home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / dev / lang / pcq12b.lzh / Include / Utils / StringLib.i < prev    next >
Text File  |  1990-08-27  |  4KB  |  194 lines

  1. {
  2.      These are some of the common C string functions.
  3. }
  4.  
  5. Function isupper(c : Char) : Boolean;
  6.     External;
  7. {
  8.     Returns True if the character is in A..Z
  9. }
  10.  
  11. Function islower(c : Char) : Boolean;
  12.     external;
  13. {
  14.     Returns True if the character is in a..z
  15. }
  16.  
  17. Function isalpha(c : Char) : Boolean;
  18.     external;
  19. {
  20.     Returns True if the character is in A..Z or a..z
  21. }
  22.  
  23. Function isdigit(c : Char) : Boolean;
  24.     external;
  25. {
  26.     Returns True if the character is in 0..9
  27. }
  28.  
  29. Function isalnum(c : Char) : Boolean;
  30.     external;
  31. {
  32.     Returns True if isalpha or isdigit is true
  33. }
  34.  
  35. Function isspace(c : Char) : Boolean;
  36.     external;
  37. {
  38.     Returns true if the character is "white space", like a space,
  39. form feed, line feed, carraige return, tab, whatever.
  40. }
  41.  
  42. Function toupper(c : Char) : Char;
  43.     external;
  44. {
  45.     If the character is in a..z, the function returns the capital.
  46. Otherwise it returns c.
  47. }
  48.  
  49. Function tolower(c : Char) : Char;
  50.     external;
  51. {
  52.     If c is in A..Z, the function returns the lower case letter.
  53. Otherwise it returns c.
  54. }
  55.  
  56. Function streq(s1, s2 : String) : Boolean;
  57.     external;
  58. {
  59.     Returns True if s1 and s2 are the same.
  60. }
  61.  
  62. Function strneq(s1, s2 : String; n : Short) : Boolean;
  63.     external;
  64. {
  65.     Returns True if the first n characters of s1 and s2 are identical.
  66. }
  67.  
  68. Function strieq(s1, s2 : String) : Boolean;
  69.     external;
  70. {
  71.     The same as streq(), but is case insensitive.
  72. }
  73.  
  74. Function strnieq(s1, s2 : String; n : Short) : Boolean;
  75.     external;
  76. {
  77.     The same as strneq(), but case insensitive.
  78. }
  79.  
  80. Function strcmp(s1, s2 : String) : Integer;
  81.     external;
  82. {
  83.     Returns an integer < 0 if s1 < s2, zero if they are equal, and > 0
  84. if s1 > s2.  Note that the returned values in 1.0 were always -1, 0 and 1;
  85. in version 1.1 that is no longer the case.
  86. }
  87.  
  88. Function stricmp(s1, s2 : String) : Integer;
  89.     external;
  90. {
  91.     The same as strcmp, but not case sensitive
  92. }
  93.  
  94. Function strncmp(s1, s2 : String; n : Short) : Integer;
  95.     external;
  96. {
  97.     Same as strcmp(), but only considers the first n characters.
  98. }
  99.  
  100. Function strnicmp(s1, s2 : String; n : Short) : Integer;
  101.     external;
  102. {
  103.     Same as strncmp, but not case sensitive
  104. }
  105.  
  106. Function strlen(s : String) : Integer;
  107.     external;
  108. {
  109.     Returns the number of characters in the string.  Note that you
  110. need strlen(s) + 1 bytes to hold the string, since the trailing zero is
  111. not counted in the length.
  112. }
  113.  
  114. Procedure strcpy(s1, s2 : String);
  115.     external;
  116. {
  117.     Copies s2 into s1, appending a trailing zero.  This is the same
  118. as C, but opposite from 1.0.  Sorry about that...
  119. }
  120.  
  121. Procedure strncpy(s1, s2 : String; n : Short);
  122.     external;
  123. {
  124.     Copies s2 into s1, with a maximum of n characters.  Appends a
  125. trailing zero.
  126. }
  127.  
  128. Procedure strcat(s1, s2 : String);
  129.     external;
  130. {
  131.     Appends s2 to the end of s1.
  132. }
  133.  
  134. Procedure strncat(s1, s2 : String; n : Short);
  135.     external;
  136. {
  137.     Appends at most n characters from s2 onto s1.
  138. }
  139.  
  140. Function strdup(s : String) : String;
  141.     External;
  142. {
  143.     This allocates a copy of the string 's', and returns a ptr
  144. }
  145.  
  146. Function strpos(s1 : String; c : Char) : Integer;
  147.     external;
  148. {
  149.     Return the position, starting at zero, of the first (leftmost)
  150. occurance of c in s1.  If there is no c, it returns -1.
  151. }
  152.  
  153. Function strrpos(s1 : String; c : Char) : Integer;
  154.     external;
  155. {
  156.     Returns the integer position of the right-most occurance of c in s1.
  157. If c is not in s1, it returns -1.
  158. }
  159.  
  160. Function Hash(s : String) : Short;
  161.     external;
  162. {
  163.     Returns the Hash value of s, computed like the AmigaDOS hash
  164. function.  You will have to cut this value (using AND or MOD) down to
  165. the size you need.
  166. }
  167.  
  168. Function IntToStr(s : String; i : Integer) : Integer;
  169.     External;
  170. {
  171.     Converts i to its character representation in s.  If i is
  172. less than zero, it will start off with a minus sign.  There will
  173. be no extra spaces before or after the number.  IntToStr returns
  174. the length of the string created, which will be between 1 and 11.
  175. }
  176.  
  177. Function AllocString(l : Integer) : String;
  178.     external;
  179. {
  180.     Allocates l bytes, and returns a pointer to the allocated memory.
  181. This memory is allocated through the new() function, so it will be returned
  182. to the system at the end of your program.  Note that the proper amount of RAM
  183. to allocate is strlen(s) + 1.
  184. }
  185.  
  186. Procedure FreeString(s : String);
  187.     external;
  188. {
  189.     This returns memory allocated by AllocString to the system.  Since
  190. the Amiga is a multitasking computer, you should always return memory you
  191. don't need to the system.
  192. }
  193.  
  194.